curl -s -L https://nvidia.github.io/libnvidia-container/centos8/libnvidia-container.repo | sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo

dnf install -y docker-ce nvidia-container-toolkit
wget "https://ghproxy.net/github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64"
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

# 配置docker加速
touch /etc/docker/daemon.json
echo '{
    "registry-mirrors": [
        "https://docker.1ms.run",
        "https://docker.lmirror.top",
        "https://docker.1panel.live",
        "https://mirror.baidubce.com",
        "https://docker.nju.edu.cn",
        "https://docker.linkos.org",
        "https://docker.mirrors.ustc.edu.cn",
        "https://registry.dockermiro.com",
        "https://reg-mirror.qiniu.com"
    ],
    "data-root": "/data/docker"
}' | sudo tee -a /etc/docker/daemon.json

# 配置运行时
nvidia-ctk runtime configure --runtime=docker

## docker image 更改地址
# /etc/docker/daemon.json
# "data-root": "/data/docker"

systemctl enable docker
systemctl restart docker

docker run --rm --runtime=nvidia --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi
